import store from '../store/index.js'
import router from './index.js'
const vipPath = ['/setting']
router.beforeEach((to, from, next) => {
  const token = store.state.tokenInfo.token
  if (!token && vipPath.includes(to.path)) {
    next('/login?originpath=' + encodeURIComponent(to.fullPath))
  } else if (token && to.path === '/login') {
    next('/')
  } else {
    next()
  }
})
export default router
